class DmsDocumenttype {
  String? id;
  String? documenttypecode;
  String? documenttypename;
  String? departmentId;
  String? departmentName;
  String? departmentcode;
  num? shelflife;
  String? saveperson;
  String? range;
  String? createUid;
  String? createBy;
  String? createDate;
  String? writeUid;
  String? writeDate;

  DmsDocumenttype({
    this.id,
    this.documenttypecode,
    this.documenttypename,
    this.departmentId,
    this.departmentName,
    this.departmentcode,
    this.shelflife,
    this.saveperson,
    this.range,
    this.createUid,
    this.createBy,
    this.createDate,
    this.writeUid,
    this.writeDate,
  });

  DmsDocumenttype copyWith({
    String? id,
    String? documenttypecode,
    String? documenttypename,
    String? departmentId,
    String? departmentcode,
    num? shelflife,
    String? saveperson,
    String? range,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
  }) {
    return new DmsDocumenttype(
      id: id ?? this.id,
      documenttypecode: documenttypecode ?? this.documenttypecode,
      documenttypename: documenttypename ?? this.documenttypename,
      departmentId: departmentId ?? this.departmentId,
      departmentcode: departmentcode ?? this.departmentcode,
      shelflife: shelflife ?? this.shelflife,
      saveperson: saveperson ?? this.saveperson,
      range: range ?? this.range,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
    );
  }

  @override
  String toString() {
    return '''DmsDocumenttype{
      id: id,
      documenttypecode: documenttypecode,
      documenttypename: documenttypename,
      departmentId: departmentId,
      departmentcode: departmentcode,
      shelflife: shelflife,
      saveperson: saveperson,
      range: range,
      createUid: createUid,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is DmsDocumenttype &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          documenttypecode == other.documenttypecode &&
          documenttypename == other.documenttypename &&
          departmentId == other.departmentId &&
          departmentcode == other.departmentcode &&
          shelflife == other.shelflife &&
          saveperson == other.saveperson &&
          range == other.range &&
          createUid == other.createUid &&
          createDate == other.createDate &&
          writeUid == other.writeUid &&
          writeDate == other.writeDate);

  factory DmsDocumenttype.fromMap(Map<String, dynamic> map) {
    return new DmsDocumenttype(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      documenttypecode: map['documenttypecode'] != false
          ? map['documenttypecode'].toString() as String?
          : "",
      documenttypename: map['documenttypename'] != false
          ? map['documenttypename'].toString() as String?
          : "",
      departmentId: map['department_id'] != false
          ? map['department_id'][0].toString() as String?
          : "",
      departmentName: map['department_id'] != false
          ? map['department_id'][1].toString() as String?
          : "",
      departmentcode: map['departmentcode'] != false
          ? map['departmentcode'].toString() as String?
          : "",
      // shelflife: map['shelflife'] != false
      //     ? map['shelflife'].toString() as String?
      //     : "",
      shelflife: map['shelflife'] != false ? map['shelflife'] : null,
      saveperson: map['saveperson'] != false
          ? map['saveperson'].toString() as String?
          : "",
      range: map['range'] != false ? map['range'].toString() as String? : "",
      createUid: map['create_uid'] != false
          ? map['create_uid'].toString() as String?
          : "",
      createBy: map['create_uid'] != false
          ? map['create_uid'][1].toString() as String?
          : "",
      createDate: map['create_date'] != false
          ? map['create_date'].toString() as String?
          : "",
      writeUid: map['write_uid'] != false
          ? map['write_uid'].toString() as String?
          : "",
      writeDate: map['write_date'] != false
          ? map['write_date'].toString() as String?
          : "",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'documenttypecode': this.documenttypecode,
      'documenttypename': this.documenttypename,
      'departmentId': this.departmentId,
      'departmentcode': this.departmentcode,
      'shelflife': this.shelflife,
      'saveperson': this.saveperson,
      'range': this.range,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.departmentId != null && this.departmentId != '')
        ['department_id', '=', int.parse(this.departmentId!)],
      if (this.documenttypecode != null && this.documenttypecode != '')
        ['documenttypecode', 'like', '%${this.documenttypecode}%'],
      if (this.documenttypename != null && this.documenttypename != '')
        ['documenttypename', 'like', '%${this.documenttypename}%'],
    ] as List;
    // if (list.length == 0) {
    //   list.add(['id', '!=', null]);
    // }
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': id!=null?int.parse(this.id!):null,
      'documenttypecode': this.documenttypecode,
      'documenttypename': this.documenttypename,
      'department_id': this.departmentId!=null?int.parse(this.departmentId!):null,
      'departmentcode': this.departmentcode,
      'shelflife': this.shelflife,
      'saveperson': this.saveperson,
      'range': this.range,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}
